package hibernate.p;

import java.util.StringTokenizer;

public class Address {
	private String nation;
	private String province;
	private String city;
	private String cityAddress;
	
	private Address(){
		this.nation=new String("null");
		this.province=this.city=this.cityAddress=this.nation;
	}
	
	public Address(String a,String b,String c,String d){
		this.setNation(a);
		this.setProvince(b);
		this.setCity(c);
		this.setCityAddress(d);
	}
	
	public void setNation(String n){
		nation=n;
		nation=nation != null ? nation : "null";
	}
	
	public String getNation(){
		return nation;
	}
	
	public void setProvince(String a){
		province=a;
		province=province != null ? province : "null";
	}
	
	public String getProvince(){
		return province;
	}
	
	public void setCity(String a){
		city=a;
		city=city != null ? city : "null";
	}
	
	public String getCity(){
		return city;
	}
	
	public void setCityAddress(String a){
		cityAddress=a;
		cityAddress=cityAddress != null ? cityAddress : "null";
	}
	
	public String getCityAddress(){
		return cityAddress;
	}
	
	public String toString(){
		return nation+"\n"+province+"\n"+city+"\n"+cityAddress;
	}
	
	public static Address parseAddress(String code){
		Address ret=new Address();
		StringTokenizer st=new StringTokenizer(code,"\n");
		ret.nation=st.nextToken();
		ret.province=st.nextToken();
		ret.city=st.nextToken();
		ret.cityAddress=st.nextToken();
		return ret;
	}
}
